var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var ResKeeper = require("AA_ResKeeper");
var CommonUtils = require("AA_CommonUtils");
var Item_CPBuff_UIBindings = require("AA_Item_CPBuff_UIBindings");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_Item_CPBuff = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.auto_ui = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.StartSet = function (e, t) {
    var o = this;
    var n = !this.node.active;
    this.node.setPosition(this.node.parent.convertToNodeSpaceAR(e.convertToWorldSpaceAR(cc.v2(0, 0))));
    this.node.active = true;
    this.auto_ui.dbAnim_selfEffect.playAnimation("newAnimation", 0);
    this.auto_ui.node_dianFather.children.forEach(function (e) {
      return e.active = false;
    });
    this.auto_ui.node_otherBuffFather.children.forEach(function (e) {
      return e.active = false;
    });
    this.unscheduleAllCallbacks();
    this.scheduleOnce(function () {
      o.ShowDian(t, n);
    }, .5);
    this.scheduleOnce(function () {
      o.ShowOtherBuff(t, n);
    }, 1);
  };
  _creator.prototype.ShowDian = function (e, t) {
    var o = this.node.convertToWorldSpaceAR(cc.v2(0, 0));
    for (var n = 0; n < e.length; n++) {
      var i = e[n].convertToWorldSpaceAR(cc.v2(0, 0));
      var a = cc.Vec2.distance(o, i) / 400;
      var r = undefined;
      if (n < this.auto_ui.node_dianFather.childrenCount) {
        r = this.auto_ui.node_dianFather.children[n];
      } else {
        (r = cc.instantiate(this.auto_ui.node_dianItem)).parent = this.auto_ui.node_dianFather;
      }
      r.scaleX = a;
      r.scaleY = 1;
      r.active = true;
      var c = CommonUtils.default.getPointAngle(o, i);
      if (t || r.angle != c) {
        r.angle = c;
        r.getComponentInChildren(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 0);
      }
    }
  };
  _creator.prototype.ShowOtherBuff = function (e, t) {
    for (var o = 0; o < e.length; o++) {
      var n = e[o].convertToWorldSpaceAR(cc.v2(0, 0));
      var i = undefined;
      if (o < this.auto_ui.node_otherBuffFather.childrenCount) {
        i = this.auto_ui.node_otherBuffFather.children[o];
      } else {
        (i = cc.instantiate(this.auto_ui.node_otherBuffItem)).parent = this.auto_ui.node_otherBuffFather;
      }
      i.active = true;
      var a = this.auto_ui.node_otherBuffFather.convertToNodeSpaceAR(n);
      if (t || i.x != a.x || i.y != a.y) {
        i.setPosition(a);
        i.getComponentInChildren(dragonBones.ArmatureDisplay).playAnimation("newAnimation", 0);
      }
    }
  };
  __decorate([_property(Item_CPBuff_UIBindings.default)], _creator.prototype, "auto_ui", undefined);
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_Item_CPBuff;